<template>
    <div class="newsinfo-container">
        <h3 class="title">{{title}}</h3>
        <p class="subtitle">
            <span>发表时间：{{newsInfo.time}}</span>
            <span>来源：{{newsInfo.src}}</span>
        </p>
        <hr>
        <div class="content" v-html="newsInfo.content">
            {{newsInfo.content}}
        </div>
        <br><br>
        <comment-box></comment-box>
    </div>
</template>

<script>
    import {Toast} from 'mint-ui'
    import comment from '../subcomponent/comment.vue'

    export default {
        name: "newsinfo",
        components:{
            'comment-box':comment
        },
        data(){
            return {
                title:this.$route.params.title,
                newsList:{},
                newsInfo:[]
            }
        },
        methods:{
            getNewsInfo(){
                this.$axios.get('/get?channel=教育&start=0&num=40&appkey=5fd40bffd271d007').then(res=>{
                    console.log(res.data.result.list)
                    this.newsList=res.data.result.list
                    for(var i=0;i<this.newsList.length;i++){
                        if(this.newsList[i].title == this.title){
                            this.newsInfo=this.newsList[i]
                        }
                    }
                },err=>{
                    Toast('获取新闻失败')
                })
            }
        },
        created() {
            this.getNewsInfo()
        }
    }
</script>

<style>
    .newsinfo-container {
        padding: 0 4px;
    }
        .title{
            font-size:16px;
            text-align: center;
            margin: 15px 0;
            color:red;
        }
        .subtitle{
            font-size:13px;
            color: #226aff;
            display: flex;
            justify-content: space-between;
        }
        .content {
            color: #333;
        }
        .content img {
                width: 100%;
            }




</style>